<template>
        
    <el-container class="home-container">
        <!-- 头部区域 -->
        <el-header>
            <div class="img1">
                <img src="../assets/2.jpg" alt="">
                <span>蓝天计划有限公司</span>
            </div>
            <el-button type="info" @click=loginOut> 退出</el-button>
        </el-header>

        <!-- 页面主体区域 -->
        <el-container>
            <!-- 侧边栏 -->
            <el-aside width="200px">
                <el-menu
                    :unique-opened="true"
                    background-color="#373D41"
                    text-color="#fff"
                    active-text-color="#409EFF"
                    router
                    :default-active="PatActive"
                >
                    <el-submenu :index="item.id+''" v-for="item in menuList" :key="item.id">
                        <template slot="title">
                            <i :class="TuObj[item.id]"></i>
                            <span>{{item.authName}}</span>
                        </template>
                            <el-menu-item :index="'/'+items.path" v-for="items in item.children" :key="items.id" @click="SavePath('/'+items.path)">
                                <i class="el-icon-menu"></i>
                                {{items.authName}}
                            </el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <!-- 右边内容 -->
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>


<script>
export default {
    data() {
        return {
            menuList:[],
            TuObj:{
                '125':'iconfont icon-morentouxiang',
                '103':'iconfont icon-kongjianfenxi',
                '101':'iconfont icon-shangpin',
                '102':'iconfont icon-changyongtubiao-fuben-65',
                '145':'iconfont icon-baobiao'
            },
            PatActive:""
        }
    },
    created() {
        this.leftMenu()
        this.PatActive = window.sessionStorage.getItem('PatActive')
    },
    methods: {
        loginOut(){
            window.sessionStorage.clear()
            this.$router.push('/login')
        },
        async leftMenu(){
           const {data:res} = await this.axios.get('menus')
         
           if(res.meta.status !== 200)return this.$message.error(res.meta.msg)
           
           this.menuList=res.data
        },
        SavePath(PatActive){
            window.sessionStorage.setItem('PatActive',PatActive)
            this.PatActive = PatActive
        }

    },
}
</script>


<style scoped lang="less">
    
    .el-header{
        background:#373D41;
        padding-left: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;
        font-size: 20px;
        .img1{
            width: 70px;
            height: 70px;
            span{
                position: absolute;
                top: 20px;
                left: 100px;
            }
            img{
                height: 100%;
                width: 100%;
            }
        }
    }

    .el-aside{
        background: #373D41;
        .el-menu{
            border-right: none;
        }
    }

    .el-main{
        background: #EAEDF1;
    }
    .home-container{
        height: 100%;
    }
    .iconfont{
        margin-right: 10px;
    }
</style>
